This disclosure relates generally to instruction processing mechanisms in a data processing system and more specifically to an improved instruction processing of a pair of setjmp/longjmp instructions in the data processing system.
A next generation supercomputer introduces hardware speculation support. Speculative data (in memory) is buffered in a L2 cache and discarded when a thread rolls back. However, backup and restoration of register states is typically left to software processes. A typical most straight-forward method of saving and restoring registers, as well as performing a control flow change of rolling-back, is via system setjmp and longjmp routines for example, as used in hardware vendor supplied support for software transactional memory (STM) and as well as in hardware vendor supplied runtime support.
In a typical compiler and symmetric multiprocessing (SMP) runtime implementation for speculation support, system setjmp/longjmp calls can be very inefficient. For example, setjmp/longjmp instructions are implemented as calls to a pre-compiled standard C language library function. Prior to the call, the caller must save all volatile registers and after the call these registers must be restored. In the setjmp function itself, all non-volatile registers are saved to memory, regardless of whether registers are live at the time of the call. In some hardware implementations there are a total of 36 non-volatile registers.
Similarly, system longjmp restores all non-volatile registers regardless of whether the registers are live. The setjmp overhead is incurred every time a transaction or speculative region is entered, regardless of whether the transaction/speculative region is rolled back. This overhead can be significant for small transactions that have few live-in registers. A common case scenario occurs in transactional memory because the transactional memory is often used as an alternative to traditional critical sections, which are typically very small. There is therefore a need to reduce the inefficiency of the current setjmp/longjmp implementations.